package com.rabbitmq;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class RabbitMqConnectionUtil {
    public static Connection getConnection() throws IOException, TimeoutException {
        //创建连接工厂
        ConnectionFactory connectionFactory = new ConnectionFactory();
        //设置主机地址
        connectionFactory.setHost("localhost");
        //设置主机端口号
        connectionFactory.setPort(5672);
        //虚拟主机名称
        connectionFactory.setVirtualHost("/user_tastmo");
        //连接用户名
        connectionFactory.setUsername("user_tastmo");
        //连接密码
        connectionFactory.setPassword("123456");
        return connectionFactory.newConnection();
    }
}
